<html>
<head><meta charset="utf-8"><title>optimizations · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html">optimizations</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160442894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160442894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160442894">(Mar 11 2019 at 01:15)</a>:</h4>
<p>This is a re-thinking of a question I asked in the Discord: what optimizations happen at MIR? Does constant propagation happen here, or is that job done at the LLVM-IR level only?</p>



<a name="160443070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160443070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160443070">(Mar 11 2019 at 01:18)</a>:</h4>
<p>There is some constant propagation, IIRC (miri) and there is potential for more.</p>



<a name="160443294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160443294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160443294">(Mar 11 2019 at 01:21)</a>:</h4>
<p>Nice! Is this documented somewhere? Maybe in RFCs? If you have a keyword I can use to look for PRs at the rustc repo, that would do as well :)</p>



<a name="160463422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160463422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160463422">(Mar 11 2019 at 09:30)</a>:</h4>
<p>The constant propagation code is in <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/const_prop.rs" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/const_prop.rs">https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/const_prop.rs</a> but it only lints if propagation would fail (aka there'd be a panic at runtime), it doesn't actually propagate right now</p>



<a name="160463449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160463449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160463449">(Mar 11 2019 at 09:30)</a>:</h4>
<p>It's also very limited, as it doesn't understand <code>if</code> and <code>match</code> right now</p>



<a name="160540026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160540026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160540026">(Mar 12 2019 at 03:31)</a>:</h4>
<p>So if I understood correctly, there's some pieces of the c.p. implemented but it's not propagating anything atm?</p>



<a name="160559312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/optimizations/near/160559312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/optimizations.html#160559312">(Mar 12 2019 at 10:38)</a>:</h4>
<p>Yes, iirc there were performance concerns. We should investigate those.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>